home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2003 November / PCWK1103B.iso / DesignCAD 3D Max PLUS trial 30 / DATA1.CAB / Example_Files / Sample_Macros / Shapes.d3m < prev    next >
Encoding:
Text File  |  2003-09-29  |  1.5 KB  |  62 lines

  1. ' This simple macro opens an ASCII text file and draws either lines
  2. ' or curves based on the content of the file.  It takes a variable
  3. ' number of coordinates for the line or curve based on the value in
  4. ' the file.
  5. '
  6. ' Dimension Arrays to hold points
  7.     Dim xval(99) 
  8.     Dim yval(99)
  9. ' Open the File, (*\ denotes the DesignCAD directory)"
  10.   Open "i", 1, "*\Sample Macros\Data.txt"
  11. ' Loop until the end of the file
  12.   Do While NOT EOF(1)
  13.     ' Get Header Line
  14.         Input #1, Header$
  15.     ' Determine Line or Curve
  16.         Det$ = LEFT$(Header$, 1)
  17.     ' Get Position of comma in line
  18.         Comma$ = ","
  19.         Pos = INSTR(Header$, Comma$)
  20.     ' Do not include the comma in the retrieved #
  21.         Pos = Pos + 1
  22.     ' Get # of points in object,
  23.     ' Change 2 below to 3 for lines for curve with over 99 points
  24.         CurNum$ = MID$(Header$, pos, 2)
  25.     ' Convert string to number
  26.         CurNum = CurNum$
  27.     ' Loop to get Points out of the ASCII file into an Array
  28.         for a = 1 to CurNum
  29.             Input #1, xone, yone
  30.             xval(a) = xone
  31.             yval(a) = yone
  32.         next a
  33.     ' Print Results of Array (for testing purposes only).
  34.         for a = 1 to CurNum
  35.             Temp$ = xval(a)
  36.             Temp2$ = yval(a)
  37.             ' Message Temp$,"  ",Temp2$
  38.         next a
  39.     ' If we're drawing a Curve
  40.         if Det$ = "C" then
  41.         ' Draw Curve with points
  42.             >Curve
  43.             {
  44.             for a = 1 to CurNum
  45.                 <pointxyz [xval(a), yval(a), 0]
  46.             next a
  47.             }
  48.         endif
  49.     ' If we're drawing a Line
  50.         if Det$ = "L" then
  51.         ' Draw Line with points
  52.             >Line
  53.             {
  54.             for a = 1 to CurNum
  55.                 <pointxyz [xval(a), yval(a), 0]
  56.             next a
  57.             }
  58.         endif
  59.   Loop
  60. ' Close File
  61.   Close #1
  62.